<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="entity.User"%>
<%@ page import="javax.servlet.http.HttpSession"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%	
	//获取项目名
	String path = request.getContextPath();
	
	//获取tomcat 协议+地址+端口号+ 获取项目名
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	//out.println(basePath);
%>

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ZZG源码分享网-资源详情</title>
<link rel="stylesheet" type="text/css"
	href="<%=basePath %>css/style.css" />
<link rel="stylesheet" type="text/css"
	href="<%=basePath %>css/common.css">

<link rel="stylesheet" type="text/css"
	href="<%=basePath %>css/animate.min.css">

<script src="<%=basePath %>jquery-3.5.1.js"></script>
<script
	src="<%=basePath %>bootstrap/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
<link rel="stylesheet"
	href="<%=basePath %>bootstrap/bootstrap-3.3.7-dist/css/bootstrap.css">
<!-- 我的CSS -->
<link rel="stylesheet" href="<%=basePath %>css/index.css">
<link rel="stylesheet" href="<%=basePath %>css/content.css">
<script src="<%=basePath %>js/content.js"></script>

</head>

<body>
	<!-- ---------------------------------------------------以下为：导航条 ----------------------------------------------------------->
	<div class="index-header clearfix">
		<div class="index- fl">
			<a href=""></a>
		</div>
		<ul class="index-nav fl" id="nav">
			<li class="active"><a
				href="<%=basePath%>htmlJs/ordUserIndex.jsp">首页</a></li>
			<li><a href="<%=basePath %>htmlJs/ordUserIndex.jsp#aboutUs">关于我们</a></li>
			<li><a
				href="<%=basePath%>userServlet?mark=showMainKindList&kind=HTML模板&root=1">HTML模板</a></li>
			<li><a
				href="<%=basePath%>userServlet?mark=showMainKindList&kind=CSS特效&root=1">CSS特效</a></li>
			<li><a
				href="<%=basePath%>userServlet?mark=showMainKindList&kind=jQuery代码&root=1">jQuery代码</a></li>
			<li><a href="">联系我们</a></li>
			<li><a href="<%=basePath%>background/ordUserJs/index/index.jsp"
				target="_blank"><strong>${user.userName}</strong></a></li>

		</ul>

		<%
			Object user =session.getAttribute("user");
			/* User user = null;
			if(u instanceof User){
				User user = (User)u;
			} */
			pageContext.setAttribute("user",user); 
		%>
		<div class="index-header-right fr" id="search">
			<a href="" class="search-btn">搜索</a>

		</div>
		<div class="clear"></div>
	</div>
	<!-- ------------------------------------------------------以下为：搜索框 ------------------------------------------------------>
	<div class="search_sec">
		<!-- 关闭搜索框 -->
		<a href="#" title="" class="close-search"><i class=" la-close"><img
				src="../images/icon5.png"></i></a>
		<div class="search_field">
			<div class="container">
				<form>
					<input type="text" name="search" placeholder="搜索...">
					<!-- 搜索图标 -->
					<button type="submit">
						<img src="../images/search2.png" alt="">
					</button>
				</form>
			</div>
		</div>
	</div>
	<!-- ------------------------------------------------------以上为：搜索框 ------------------------------------------------------>

	<!-- ------------------------------------------------------以上为：导航条 ------------------------------------------------------>

	<div id="mian-html">

		<div id="addr"></div>
		<div id="header">

			<ul class="list-group">
				<li class="list-group-item list-group-item-success">当前位置：首页 > <span>模块类别</span>
					>
				</li>
				<li class="list-group-item list-group-item-info">
					<h2>${rs.rsName}</h1>
				</li>
			</ul>
		</div>

		<!-- ---------------------------------------以下为：主要内容----------------------------------------- -->
		<div class="row" id="row">
			<div class="col-md-8">
				<div>
					<h3>
						<span class="label label-success">资源介绍</span>
					</h3>
					<div class="comment-list">
						<div>
							<p>${rs.rsDes}</p>
						</div>
					</div>
				</div>
				<hr id="solid-line">

				<!-- ------------------------------------------以下为：点赞推荐------------------------- -->
				<div>
					<h3>
						<span class="label label-success">资源点评</span>
					</h3>

					<div class="btn-group">
						<button id="bnt-rsF" type="button" class="btn btn-info">
							<span class="glyphicon glyphicon-thumbs-up" aria-hidden="true"></span>
						</button>
						<button type="button" class="btn btn-default dropdown-toggle">
							<span>${rs.rsFavors}</span>
						</button>

					</div>

					<div class="btn-group">
						<button id="bnt-rsA" type="button" class="btn btn-info">
							<span class="glyphicon glyphicon-thumbs-down" aria-hidden="true"></span>
						</button>
						<button type="button" class="btn btn-default dropdown-toggle">
							<span>${rs.rsAgainsts}</span>
						</button>
					</div>

					<script type="text/javascript">
                    
                    
                    $("#bnt-rsA").click(function(){
                		var rsA = ${rs.rsAgainsts+1};
                		var rsId = ${rs.rsId};   	
                		console.log(rsA,rsId);
                		$.ajax({
                			
                			url:"<%=basePath%>resourceServlet",
                    		type:"get",
                    		data:"mark=clickRsA&rsA="+rsA+"&rsId="+rsId,
                    		dataType:"json",
                    		success:function(mes){
                    			if(mes==true){
                    				alert("反对成功！");
                    				window.location.href = "<%=basePath%>userServlet?mark=showContent&root=1&rsId="+rsId;
                    			}
                    		}
                		});
                		
                	});
                    	
                    	$("#bnt-rsF").click(function(){
                    		var rsF = ${rs.rsFavors+1};
                    		var rsId = ${rs.rsId};   	
                    		console.log(rsF,rsId);
                    		$.ajax({
                    			
                    			url:"<%=basePath%>resourceServlet",
                        		type:"get",
                        		data:"mark=clickRsF&rsF="+rsF+"&rsId="+rsId,
                        		dataType:"json",
                        		success:function(mes){
                        			console.log("mes:"+mes);
                        			if(mes==true){
                        				alert("点赞成功！");
                        				// 用法
                        				
                        				window.location.href = "<%=basePath%>userServlet?mark=showContent&root=1&rsId="+rsId;
                        				//window.location.reload();
                        				
                        			}else{
                        				alert("点赞失败！");
                        			}
                        			
                        		}
                    		});
                    		
                    	});
     				</script>

					<!-- ------------------------------------------以上为：点赞推荐------------------------- -->

				</div>
				<hr id="solid-line">

				<!--------------------------------------- 资源下载 ------------------>
				<div>

					<h3>
						<span class="label label-info"><a id="btn-down"
							href="/resourceSharing/DownloadServlet?filename=${rs.rsName}.jpg">下载资源</a></span>
					</h3>

				</div>
				<hr id="solid-line">


				<script type="text/javascript">
                	
                	$("#btn-down").click(function(){
                		var rsDownloads = ${rs.rsDownloads+1};
                		var rsId = ${rs.rsId};   
                		
                		console.log(rsDownloads,rsId);
                		$.ajax({
                			
                			url:"<%=basePath%>resourceServlet",
                    		type:"get",
                    		data:"mark=clickRsDownloads&rsDownloads="+rsDownloads+"&rsId="+rsId,
                    		dataType:"json",
                    		success:function(mes){
                    			
                    			if(mes==true){
                    				//alter("点赞成功");
                    			}
                    		} 
                		});
                	})
                </script>
				<!-- ------------------------------------------以下为：评论列表和评论区------------------------------->
				<div>
					<h3>
						<span class="label label-success">评论列表</span>
					</h3>
					<c:forEach items="${cPage.pageList}" var="cp">
						<div class="comment-list">
							<div>
								<p>

									<span><strong
										style="color: rgb(117, 187, 172); font-size: medium;">${cp.userName}：</strong></span>
									<span>发表于</span> &nbsp; <span><strong
										style="color: rgb(117, 187, 172);">${cp.cTime}</strong></span>
								</p>
								<p>${cp.cContent }</p>
								<p>
									<span><a id="cFavors" href="">支持</a></span> <span>(${cp.cFavors})</span>
									<span><a href="">反对</a></span> <span>(${cp.cAgainsts})</span>
								</p>
							</div>

						</div>
					</c:forEach>

					<script type="text/javascript">
                	
                	$("#cFavors").click(function(){
                		var cFavors = ${cp.cFavors+1};
                		var cId = ${cp.cId};   
                		alert(cFavors);
                		console.log(cFavors);
                		$.ajax({
                			
                			url:"<%=basePath%>resourceServlet",
                    		type:"get",
                    		data:"mark=clickCfavors&cFavors="+cFavors+"&cId="+cId,
                    		dataType:"json",
                    		success:function(mes){
                    			if(mes==true){
                    				alter("点赞成功");
                    			}
                    		} 
                		});
                	});
                </script>

					<!--分页按钮-->
					<nav aria-label="Page navigation" id="page-nav">
						<ul class="pagination">
							<!-- <%=basePath%>userServlet?mark=showContent&root=1&rsId=${hp.rsId} -->
							<li><a
								href="<%=basePath%>userServlet?mark=showContent&root=1&rsId=${rs.rsId}&current_page=1">首页</a></li>
							<li><a
								href="<%=basePath%>userServlet?mark=showContent&root=1&rsId=${rs.rsId}&current_page=${cPage.prePage }"
								aria-label="Previous"> <span aria-hidden="true">&laquo;</span>
							</a></li>
							<li><a href="#">${cPage.currentPage}</a></li>

							<li><a
								href="<%=basePath%>userServlet?mark=showContent&root=1&rsId=${rs.rsId}&current_page=${cPage.nextPage }"
								aria-label="Next"> <span aria-hidden="true">&raquo;</span>
							</a></li>
							<li><a
								href="<%=basePath%>userServlet?mark=showContent&root=1&rsId=${rs.rsId}&current_page=${cPage.countPage }">尾页</a></li>
						</ul>
					</nav>
				</div>
				<hr id="solid-line">
				<div>
					<h3>评论区</h3>
					<div id="comment-area">
						<textarea id="comment" class="form-control" rows="3"></textarea>
						<button id="subComment" class="btn btn-info">发表评论</button>
					</div>
				</div>
				<script type="text/javascript">
                	$("#subComment").click(function(){
                		var cComment = $("#comment").val();
                		var rsId = ${rsId};
                		var userId = ${user.userId};
                		console.log(cComment,rsId,userId);
                		if(cComment==null || cComment==""){
                			alert("评论不能为空!");
                			return;
                		}
                		$.ajax({
                    			url:"<%=basePath%>resourceServlet",
                        		type:"get",
                        		data:"mark=writeC&cComment="+cComment+"&rsId="+rsId+"&userId="+userId,
                        		dataType:"json",
                        		success:function(mes){
                        			if(mes==true){
                        				alert("评论成功");
                        				window.location.href = "<%=basePath%>userServlet?mark=showContent&root=1&rsId="+rsId;
                        			}else{
                        				alert("评论失败");
                        				return;
                        			}
                        		} 
                    		});
                		
                			
                		
					
                	});
                </script>
				<!-- ------------------------------------------以上为：评论列表和评论区------------------------------->
				<%-- <script type="text/javascript">
                	
                	$("#cFavors").click(function(){
                		var cFavors = ${cp.cFavors+1};
                		var cId = ${cp.cId};   
                		alert(cFavors);
                		console.log(cFavors,cId);
                		$.ajax({
                			
                			url:"<%=basePath%>resourceServlet",
                    		type:"get",
                    		data:"mark=clickCfavors&cFavors="+cFavors+"&cId="+cId,
                    		dataType:"json",
                    		success:function(mes){
                    			if(mes==true){
                    				alter("点赞成功");
                    			}
                    		} 
                		});
                	})
                </script> --%>
			</div>

			<!-- ---------------------------------------以下为：主要内容----------------------------------------- -->


			<!-- ---------------------------------------以下为：资源信息详情 ---------------------------------------->
			<div class="col-md-4">
				<h2 id="rank-h2">资源信息</h2>
				<hr>

				<p>
					<span><a></a></span>
				</p>

				<p>
					<span></span>
				</p>
				<ul class="list-group">
					<li class="list-group-item list-group-item-success"><span
						class="label label-danger">大小</span> <span>${rs.rsSize}M</span></li>
					<li class="list-group-item list-group-item-info"><span
						class="label label-warning">类别</span> <span>${rs.rsCategory}</span></li>
					<li class="list-group-item list-group-item-warning"><span
						class="label label-info">评分</span> <span>${rs.rsScore}</span></li>
					<li class="list-group-item list-group-item-danger"><span
						class="label label-success">发布时间</span> <span>${rs.rsTime }</span></li>
					<li class="list-group-item list-group-item-success"><span
						class="label label-primary">下载次数</span> <span>${rs.rsDownloads }</span></li>
					<li class="list-group-item list-group-item-info"><button
							type="button" class="btn btn-danger">
							<a id="btn-down-2"
								href="/resourceSharing/DownloadServlet?filename=${rs.rsName}.jpg"
								style="color: white">下载资源</a>
						</button></li>
				</ul>
			</div>
			<script type="text/javascript">
                	
                	$("#btn-down-2").click(function(){
                		var rsDownloads = ${rs.rsDownloads+1};
                		var rsId = ${rs.rsId};   
                		
                		console.log(rsDownloads,rsId);
                		$.ajax({
                			
                			url:"<%=basePath%>resourceServlet",
                    		type:"get",
                    		data:"mark=clickRsDownloads&rsDownloads="+rsDownloads+"&rsId="+rsId,
                    		dataType:"json",
                    		success:function(mes){
                    			
                    			if(mes==true){
                    				//alter("点赞成功");
                    			}
                    		} 
                		});
                	})
             </script>
			<!-- ---------------------------------------以上为：资源信息详情 ---------------------------------------->

		</div>


	</div>





	<!---------------------------------------------------------footer-------------------------------------------------------------->
	<div class="index-footer" id="footer">
		<div class="clearfix index-footer-info index-con">
			<div class=" fl"></div>
			<div class="lianxi fl">
				<h2>联系方式</h2>
				<p>QQ： 2911620942</p>

				<P>地址：JJU智能调度实验室</P>
				<p></p>
			</div>
			<!-- <div class="phone fl">			
						xxx
					</div> -->
			<div class="erweima fr">
				<!-- <img src="images/pic1.jpg">
						<p>二维码</p> -->
			</div>
		</div>

		<div class="index-footer-bottom">
			<div class="index-con clearfix">
				<p class="fl">版权所有 © 2020 JJU_干干</p>
				<a href="#" target="_blank" class="fr" id="designer">设计：ZZG_干干</a>
			</div>
		</div>
	</div>
	<div class="clear"></div>
	</article>
	</div>

	<script type="text/javascript"
		src="http://www.5imoban.net/download/jquery/jquery-3.2.1.min.js"></script>
	<script type="text/javascript"
		src='<%=basePath %>js/modernizr.custom.js'></script>
	<!-- 搜索框 -->
	<script src="<%=basePath %>js/more.js"></script>
	<script
		src="http://www.5imoban.net/download/swiper/swiper-4.4.2.min.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/main.js"></script>
	<script type='text/javascript' src='<%=basePath %>js/base.js'></script>
	<script type="text/javascript" src='<%=basePath %>js/app.js'></script>
	<script>
        var swiper = new Swiper('.index-banner.swiper-container', {
            speed: 600,
            parallax: true,
            navigation: {
                nextEl: '.swiper-button-next',
                prevEl: '.swiper-button-prev',
            },
        });
        scrolly.init({
            wrapper: '#bloc',
            targets: '.scr-el',
            bgParallax: true,
            wrapperSpeed: 0.08
        });
    </script>

</body>

</html>